package com.fk.dao.impl;

import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;

import com.fk.entity.Admin;
import com.fk.uitl.DBManager;

public class AdminDaoImpl {
	public Admin getAdminByName(String username ) {
		Admin admin = null;
		Connection conn = DBManager.getConnection();
		Statement st = null;
		ResultSet rs = null ;
		try {
			st = conn.createStatement();
			rs = st.executeQuery("select * from admin where userName = '"+username+"'");
			while(rs.next()) {
				int uId = rs.getInt(1);
				String userName = rs.getString("userName");
				String password = rs.getString("password");
				admin = new Admin(uId, userName, password);
			}
			return admin;
		} catch (SQLException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
			return null;
		}finally {
			DBManager.closeAll(conn, st, rs);
		}
	}
}
